package utils;

import cn.hutool.core.convert.Convert;

import java.util.ArrayList;
import java.util.List;

public class StringUtils {

    private static final String PREFIX_URL = "http://ahtv-obs.obs.cn-north-4.myhuaweicloud.com:80/";

    public static void main(String[] args) {

        String urls = "http://ahtv-obs.obs.cn-north-4.myhuaweicloud.com:80/16027591927866249.mp4,http://ahtv-obs.obs.cn-north-4.myhuaweicloud.com:80/16027591927871634.mp4,http://ahtv-obs.obs.cn-north-4.myhuaweicloud.com:80/16027591927876897.mp4,http://ahtv-obs.obs.cn-north-4.myhuaweicloud.com:80/16027591927871701.mp4,http://ahtv-obs.obs.cn-north-4.myhuaweicloud.com:80/16027591927872317.jpeg,http://ahtv-obs.obs.cn-north-4.myhuaweicloud.com:80/16027591927875161.jpeg";

        String[] urlArr = Convert.toStrArray(urls);
        List<String> imageUrls = new ArrayList<>();
        List<String> videoUrls = new ArrayList<>();
        for (int i = 0; i < urlArr.length; i++) {
            String url = urlArr[i];
            if (url.endsWith(".jpg") || url.endsWith(".png") || url.endsWith(".jpeg")) {
                imageUrls.add(url);
            } else if (urlArr[i].endsWith(".mp4")) {
                videoUrls.add(url);
                String url2 = url.substring(url.indexOf(PREFIX_URL) + PREFIX_URL.length());
                System.out.println("url = " + url2);
            }
        }
        System.out.println("imageUrls = " + imageUrls);
        System.out.println("videoUrls = " + videoUrls);

        String coverUrl = "http://dbxz1.ahtv.cn/butelvod/a4f52a55-44a4-4ba4-9430-794298ce01dd.jpg?";
        if (coverUrl.contains("?")) {
            coverUrl = coverUrl.substring(0, coverUrl.indexOf("?"));
        }
        System.out.println("coverUrl = " + coverUrl);
    }
}
